/*
 * 题目描述：十进制和十三进制之间转换
 * 
 * 坑：需要注意添零
 */
#include <iostream>
#include <list>
using namespace std;
int main() {
    int red, green, blue;
    cin >> red >> green >> blue;
    list<char> l;
    while (blue != 0) {
        int res = blue % 13;
        blue /= 13;
        if (res >= 10) {
            l.push_front('A' + res - 10);
        }else{
            l.push_front('0' + res);
        }
    }
    while (l.size() != 2) {
        l.push_front('0');
    }
    while (green != 0) {
        int res = green % 13;
        green /= 13;
        if (res >= 10) {
            l.push_front('A' + res - 10);
        }else{
            l.push_front('0' + res);
        }
    }
    while (l.size() != 4) {
        l.push_front('0');
    }
    while (red != 0) {
        int res = red % 13;
        red /= 13;
        if (res >= 10) {
            l.push_front('A' + res - 10);
        }else{
            l.push_front('0' + res);
        }
    }
    while (l.size() != 6) {
        l.push_front('0');
    }
    cout << "#";
    while (!l.empty()) {
        cout << l.front();
        l.pop_front();
    }

    return 0;
}